package com.xxd.rpt2.Entity

import javax.persistence.Entity
import javax.persistence.FetchType
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.persistence.JoinColumn
import javax.persistence.JoinTable
import javax.persistence.ManyToMany
import javax.persistence.OneToOne
import javax.persistence.Table

/**
 * @Author XuXd
 * @Description: 功能菜单
 * @CreateDate: 14:03 2019-09-11
 * @Modified by: *
 */
@Entity
@Table(name="rpt2_menu")
class Menu {
    @Id
    @GeneratedValue
    int id
    String code
    String name
    String path
    int state = 1

    @OneToOne
    @JoinColumn(name="parent_id" ,referencedColumnName = "id")
    Menu parentMenu


    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name="rpt2_menu_permission",joinColumns = [@JoinColumn(name="menu_id",referencedColumnName = "id") ],
            inverseJoinColumns = [@JoinColumn(name="permission_id",referencedColumnName = "id")])
    List<Permission> permissionList
}
